package cn.jsj.fixed.asset;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *添加固定资产处理类
 * @author LI
 *
 */
 public class AddFixedAssetInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("添加固定资产类！！");

		 //新建固定资产对象
		 cn.jsj.pojo.TblFixedAssets tfa=new cn.jsj.pojo.TblFixedAssets();
		 tfa.setBuyTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("fixedAssetTime").trim()));
		 tfa.setGoodsName(request.getParameter("fixedAssetName").trim());
		 tfa.setPurchaseNumber(Integer.parseInt(request.getParameter("fixedAssetNumb").trim()));
		 tfa.setGoodsMoney(Integer.parseInt(request.getParameter("fixedAssetMoney").trim()));
		 tfa.setGoodsBrief(request.getParameter("fixedAssetRemark").trim());
		 // 设置报销数量为0
		 tfa.setWipeOutNumber(0);

		 //调试信息
		  cn.jsj.utils.SysLogger.PrintInfo("canshu----------->"+request.getParameter("fixedAssetName")+"   "+request.getParameter("fixedAssetTime"));

		  //保存
		  cn.jsj.dao.TblFixedAssetsDAO tfad=new cn.jsj.dao.TblFixedAssetsDAO();
		  int saveResult=tfad.saveFixedAsset(tfa);

		  //调试信息
		  cn.jsj.utils.SysLogger.PrintInfo("保存结果------------->"+saveResult);

		  //输出流
		  java.io.PrintWriter out=response.getWriter();
		  //如果保存成功
		  if(saveResult==1){
			  out.println("{message:'添加成功！'}");
		  }
		  else{
			  out.println("{message:'添加失败!'}");
		  }
		  out.flush();
		  out.close();
	 }
}